package com.teacold.customdemo.chapter_one;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * 第一章 1.1
 */
public class BaseView extends View {
    private Paint mPaint;

    public BaseView(Context context) {
        super(context);
        mPaint = new Paint();
    }

    public BaseView(Context context, AttributeSet attrs) {
        this(context);
    }

    public BaseView(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawRGB(255,0,255);
        mPaint.setColor(0xFFFF0000);//设置颜色
        mPaint.setStyle(Paint.Style.FILL);//设置填充样式
        mPaint.setStrokeWidth(50);//设置画笔的宽度  50px
        mPaint.setAntiAlias(true);//是否抗锯齿
        canvas.drawCircle(190,200,150,mPaint);
        mPaint.setColor(0x7EFFFF00);//设置颜色
        canvas.drawCircle(190,200,100,mPaint);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Paint.Style.STROKE);


        mPaint.setColor(Color.BLUE);
        RectF rectF=new RectF(100,10,300,100);
        canvas.drawRect(rectF,mPaint);//矩形
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setColor(Color.RED);
        canvas.drawOval(rectF,mPaint);//椭圆

        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(5);
        RectF rectF2=new RectF(200,200,500,900);
        mPaint.setColor(Color.DKGRAY);
        canvas.drawArc(rectF2,60,90,false,mPaint);





    }
}
